package Converter;

import com.example.onehourspring.datacess.Student;
import com.example.onehourspring.dto.StudentDTO;

//用于定义一个转换，将student对象转换成StudentDTO对象
public class StudentConverter {

    public static StudentDTO converterStudent(Student student){
        StudentDTO studentDTO = new StudentDTO();
        studentDTO.setId(student.getId());
        studentDTO.setName(student.getName());
        studentDTO.setEmail(student.getEmail());
        return studentDTO;
    }

    //新增学生数据，需要将前端的studentDTO对象converter成student对象
    public static Student converterStudent(StudentDTO studentDTO){
        Student student = new Student();
        student.setName(studentDTO.getName());
        student.setEmail(studentDTO.getEmail());
        return student;
    }
}
